package com.itheima.jdk8_DateDemo;


import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;

public class Work1 {
    public static void main(String[] args) {

        //获取当天发货的系统时间
        LocalDate sendDate = LocalDate.now();
        LocalTime sendTime = LocalTime.of(15, 0, 0, 0);
        LocalDateTime sendDateTime = LocalDateTime.of(sendDate, sendTime);
        System.out.println("每日发货时间:" + sendDateTime);

        //获取下单的时间
        LocalDateTime now = LocalDateTime.now();
        System.out.println("下单时间:" + now);
        //获取下单日期与时间
        LocalDate nowLocalDate = now.toLocalDate();
        LocalTime nowLocalTime = now.toLocalTime();
        //判断是否在15点之后


        //判断下单日是否为周日,且返回相关
        booleanSendDate(sendTime, nowLocalDate, nowLocalTime);


        /**
         * 首先转换为string,比较是否为同一天
         SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
         String ssDate = sdf.format(sendDate);
         String snDate = sdf.format(nowLocalDate);

         ssDate.equals(snDate);*/
    }

    private static void booleanSendDate(LocalTime sendTime, LocalDate nowLocalDate, LocalTime nowLocalTime) {
        if (nowLocalDate.getDayOfWeek() == DayOfWeek.SUNDAY) {
            System.out.println("明天发货");
        } else if (nowLocalDate.getDayOfWeek() == DayOfWeek.SATURDAY && nowLocalTime.isAfter(sendTime)) {
            System.out.println("周一发货");
        } else if (nowLocalTime.isAfter(sendTime)) {
            System.out.println("明天发货");
        } else {
            System.out.println("今天发货");
        }
    }


}
